﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.SharePoint.Administration;

namespace MS.InformationManagement.DocumentIDServiceApp
{
    [Guid("6565077D-7478-4EAB-84E8-3246E0DD7E3B")]
    [SupportedServiceApplication("E6295DED-BD78-4D5E-B654-9DFB68531E75", "1.0.0.0", typeof(DocumentIDServiceApplicationProxy))]
    public sealed class DocumentIDServiceProxy : SPIisWebServiceProxy, IServiceProxyAdministration
    {
        #region Constructors

        public DocumentIDServiceProxy()
            : base()
        { }

        public DocumentIDServiceProxy(SPFarm farm)
            : base(farm)
        { }

        #endregion

        #region IServiceProxyAdministration

        public SPServiceApplicationProxy CreateProxy(Type serviceApplicationProxyType, string name, Uri serviceApplicationUri, SPServiceProvisioningContext provisioningContext)
        {
            if (serviceApplicationProxyType != typeof(DocumentIDServiceApplicationProxy))
                throw new NotSupportedException("Invalid Service Application type, expected DocumentIDServiceApplicationProxy");

            return new DocumentIDServiceApplicationProxy(name, this, serviceApplicationUri);
        }

        public SPPersistedTypeDescription GetProxyTypeDescription(Type serviceApplicationProxyType)
        {
            return new SPPersistedTypeDescription("DocumentID Service Proxy", 
                "Connects to the DocumentID Service.");
        }

        public Type[] GetProxyTypes()
        {
            return new Type[] { typeof(DocumentIDServiceApplicationProxy) };
        }

        #endregion
    }
}
